"use server"; import { BannerRep, GroupType, NoticeRep, PromotionRep } from "@/api/home"; import Box from "@/components/Box"; import HomeActions from "./_home/HomeActions"; import HomeCard from "./_home/HomeCard"; import HomeGames from "./_home/HomeGames"; import HomeMessage from "./_home/HomeMessage"; import HomeNoticeBar from "./_home/HomeNoticeBar"; import HomePrize from "./_home/HomePrize"; import HomePromotion from "./_home/HomePromotion"; import HomeSearch from "./_home/HomeSearch"; import HomeSwiper from "./_home/HomeSwiper"; import HomeTabs from "./_home/HomeTabs"; const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; const TIME = 30; const getGames = async (): Promise => { try { const data = await fetch(`${BASE_URL}/v1/api/front/game_list`, { method: "POST", body: JSON.stringify({ template_key: "g_temp_9" }), next: { revalidate: TIME }, }).then((res) => res.json()); console.log(`🎯🎯🎯🎯🎯-> in page.tsx on 24`, data.data); return data.data; } catch (err) { return []; } }; const getBanners = async (): Promise => { try { const response = await fetch(`${BASE_URL}/v1/api/front/banner_list`, { method: "POST", body: JSON.stringify({}), headers: { language: "zh", }, next: { revalidate: TIME }, }).then((res) => res.json()); return response.data; } catch (err) { return Promise.resolve([]); } }; const getNotices = async (): Promise => { try { const response = await fetch(`${BASE_URL}/v1/api/front/marquee`, { method: "POST", body: JSON.stringify({}), headers: { language: "zh", }, next: { revalidate: TIME }, }).then((res) => res.json()); return response.data; } catch (err) { return []; } }; const getActivities = async (): Promise => { try { const response = await fetch(`${BASE_URL}/v1/api/front/activity_home`, { method: "POST", body: JSON.stringify({}), headers: { language: "zh", }, next: { revalidate: TIME }, }).then((res) => res.json()); return response.data; } catch (err) { return []; } }; const getPromotions = async (): Promise => { try { const response = await fetch(`${BASE_URL}/v1/api/front/pop_list`, { method: "POST", body: JSON.stringify({}), headers: { language: "zh", }, next: { revalidate: TIME }, }).then((res) => res.json()); return response.data; } catch (err) { return []; } }; export default async function Page() { const [group = [], banners = [], notices = [], activities = [], promotions = []] = await Promise.all([ getGames(), getBanners(), getNotices(), getActivities(), getPromotions(), ]); return (
{group.map((item) => { return ; })}
); }